home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / misc / vpan100.zip / SU_BP.CPP < prev    next >
C/C++ Source or Header  |  1995-01-19  |  5KB  |  228 lines

  1. //
  2. //  AC SUSCEPTEMETER
  3. //
  4. //     BUTTON AND PAINT PROCEDURES (bp and pp) 
  5. //
  6. //                       |     Written by O.Rasizade
  7. //                 |       (c) Sept 1992, 1993
  8. //                       |
  9. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  10.  
  11.  
  12. #include <vphead.h>    // must be included first
  13. #pragma hdrstop
  14.  
  15. #include <vpbase.h>
  16. #include <vpboard.h>
  17. #include <vpoutbox.h>
  18. #include <vpinbox.h>
  19. #include <vpindic.h>
  20. #include <vpgraph.h>
  21. #include <vpbutt.h>
  22. #include <vputil.h>
  23.  
  24. #include <suscept.h>
  25. #include "su_bp.h"
  26.  
  27. #define CHOOSE_TITLE_FONT    0
  28. #define CHOOSE_TITLE_FONT_SIZE    1
  29.  
  30. //++++++++++++++++ GLOBAL VARIABLES ++++++++++++++++
  31. int K_gain_temp;            // temporary gain for choosing indicator
  32. //------------------------ AMPLIFIER ----------------------------
  33. //------------------ GAIN CONSTANTS
  34. #define N_GAIN            11    // number of gain sets
  35. const struct{byte code;
  36.          char *value;
  37.          long Ku;
  38.          }    gain[N_GAIN]={    {0x0a,"150*Kf",150000},
  39.                 {0x09,"300*Kf",300000},
  40.                 {0x0b,"450*Kf",450000},
  41.                 {0x06,"600*Kf",600000},
  42.                 {0x05,"1200*Kf",1200000},
  43.                 {0x07,"1800*Kf",1800000},
  44.                 {0x14,"2400*Kf",2400000},
  45.                 {0x26,"600",600},
  46.                 {0x25,"1200",1200},
  47.                 {0x27,"1800",1800},
  48.                 {0x34,"2400",2400}
  49.                   };
  50.  
  51. //++++++++++++++++ REFERENCES TO OBJECTS ++++++++++++++++
  52.  
  53. extern indbutton *butHeater;
  54. extern Indicator<double> *indDisbal,*indModule,*indR;
  55. //extern TSInbox *ptibBalabce,*ptibDC,*ptibAC;
  56. _Indicator *indGain,*indChoose;
  57.  
  58. //+++++++++++++++++++ PROCEDURES ++++++++++++++++++++++
  59.  
  60. //---------------------- CAMAC CONTROL PANEL BUTTONS ----
  61.  
  62.     //---------------- HEATER---
  63. void far bpHeater(void)
  64. {
  65.  butHeater->Invert();
  66.  (butHeater->on)?HeatON:HeatOFF;
  67. }
  68.  
  69.     //---------------- ENTER BALANCE  ---
  70. void far bpEnterBal(void)// popup
  71. {
  72.  Enter("Enter","Angle(rad) = ","%f", &fi);
  73.  sinfi=sin(fi); cosfi=cos(fi);
  74. }
  75.  
  76.     //---------------- R INDICATOR ---
  77. void far ppR(void)
  78. {             // perm ind
  79.  indR->Paint();
  80.  indR->Put(R);
  81. }
  82.  
  83. void far bpR(void)
  84. {
  85.  ppR();
  86.  indR->MkActive();
  87. }
  88.  
  89.  
  90.     //---------------- DISBALANCE ANGLE ----------
  91. void far ppDisbal(void)
  92. {             // perm ind
  93.  indDisbal->Paint();
  94.  indDisbal->Put(disbalance);
  95. }
  96.  
  97. void far bpDisbal(void)
  98. {
  99.  ppDisbal();
  100.  indDisbal->MkActive();
  101. }
  102.     //---------------- MODULE ----------
  103. void far ppModule(void)
  104. {             // perm ind
  105.  indModule->Paint();
  106.  indModule->Refresh();
  107. }
  108.  
  109. void far bpModule(void)
  110. {
  111.  ppModule();
  112.  indModule->MkActive();
  113. }
  114.  
  115. //------------------------------------ CHOOSE GAIN ----------
  116.  
  117. void far  bpGain(void)
  118. {
  119. #define chBUTSHF     30
  120. #define chINDSHF     20
  121. int ax0=maxx>>1,ay0=maxy>>2;
  122.  
  123.     //------------------- COLOR setting for indicators
  124. const indicatorcolors LCDred={
  125.                RED,    // color of title
  126.                DARKGRAY,// foreground color
  127.                YELLOW    // background color
  128.                };
  129. const indicatorcolors LCDgreen={
  130.                LIGHTGREEN,    // color of title
  131.                DARKGRAY,// foreground color
  132.                YELLOW    // background color
  133.                };
  134. butsystem bsGain;
  135.  
  136. settextstyle(CHOOSE_TITLE_FONT,HORIZ_DIR,CHOOSE_TITLE_FONT_SIZE);
  137. _Indicator _indGain(
  138.         ax0+chINDSHF,ay0+y__yy(textheight("p"))+4*SPACING,
  139.         FIXED,"Current Gain",
  140.         10,"%s",    // width of disp in chars,format
  141.         UNFRAMED,procNULL,
  142.         0,1,        //font and size of number
  143.         SMALL_FONT,4,    //font and size of title
  144.         plaquecoldflt,LCDred),
  145.  
  146.     _indChoose(
  147.         ax0+chINDSHF,_indGain.ymax,FIXED,"Choose Gain",
  148.         10,"%s",    // width of disp in chars,format
  149.         UNFRAMED,procNULL,
  150.         0,1,        //font and size of number
  151.         SMALL_FONT,4,    //font and size of title
  152.         plaquecoldflt,LCDgreen);
  153.  
  154.  indGain=&_indGain;
  155.  indChoose=&_indChoose;
  156. int axmax=_indChoose.xmax+chINDSHF;
  157.     //---------------- Buttons ------
  158. int  bxsz=(axmax-ax0-2*chBUTSHF)>>1;
  159. butgrp gr1(ax0+chBUTSHF,_indChoose.ymax,bxsz,18);
  160.   button butDec("<",'<',',',bpDec,SMALL_FONT,4);
  161.   button butInc(">",'>','.',bpInc,SMALL_FONT,4);
  162.  gr1.ShiftToX(ax0+chBUTSHF+(bxsz>>1));
  163.  gr1.ShiftToY(butInc.ymax+6);
  164.   button butEnter("Enter",13,13,bpEnter,SMALL_FONT,4);
  165.  
  166. Board ChooseGain(ax0,ay0,POPUP,"Pickup Amplifier",
  167.          axmax-ax0,butEnter.ymax-ay0+chBUTSHF,// size of board
  168.          procNULL,
  169.          CHOOSE_TITLE_FONT,CHOOSE_TITLE_FONT_SIZE);
  170.  
  171.     //---------------- Paint whole board
  172. ChooseGain.Paint();
  173.  
  174. _indGain.Paint();
  175. _indChoose.Paint();
  176.  
  177. _indGain.Put(gain[K_gain].value);
  178. _indChoose.Put(gain[K_gain].value);
  179.  
  180. gr1.Paint();
  181.  
  182. K_gain_temp=K_gain;
  183.  
  184. bsGain.NextButton();
  185. bsGain.Loop(procDummy);
  186. ChooseGain.Remove();
  187. }
  188.         //------ CHOOSE GAIN BUTTON PROCs ----
  189. void far  bpInc(void)
  190. {
  191.  if (K_gain_temp< N_GAIN-1)
  192.    K_gain_temp++;
  193.  else
  194.    K_gain_temp=6;
  195.  indChoose->Put(gain[K_gain_temp].value);
  196. }
  197.  
  198. //---------
  199. void far  bpDec(void)
  200. {
  201.  if (K_gain_temp> 0)
  202.    K_gain_temp--;
  203.  else
  204.    K_gain_temp=0;
  205.  indChoose->Put(gain[K_gain_temp].value);
  206. }
  207.  
  208. //---------
  209. void far  bpEnter(void)
  210. {
  211.  K_gain=K_gain_temp;
  212.  indGain->Put(gain[K_gain].value);
  213.  gainAmpSusc=gain[K_gain].code;
  214.  setAmpl_2(gainAmpSusc);    //gain for suscept
  215. }
  216. //----------
  217.  
  218. //----------------------------- QUIT ---
  219. void far  bpQuit(void)
  220. {
  221.  object::SaveCnfg(CNF_NAME);
  222.  camDisInt();
  223.  quitSuscept();
  224.  QuitVirtualPanels();
  225.  exit(0);
  226. }
  227.  
  228.